<?php
/**
 * @功能 处理数据库
 */
$link = require_once ('./config.php');
require_once ('./function.php');
$sql = "select * from talk";
$data = mysqli_query($link, $sql);
//$color=array('success','info','warning','danger');
while ($arr= mysqli_fetch_assoc($data)){ 
    $location = position($arr['ip']);
    $sql="UPDATE talk SET location='{$location}' WHERE id=".$arr['id'];
    mysqli_query($link, $sql);
}

/*//设置气泡颜色
$sql="select * from talk";
$data=mysqli_query($link, $sql);
$color=array('success','info','warning','danger');
while ($arr= mysqli_fetch_assoc($data)){ 
    print_r($arr);
    $ip=$arr['ip']{strlen($arr['ip'])-1};
    $colorno=$ip%4;  
    $sql="UPDATE talk SET color='{$color[$colorno]}' WHERE id=".$arr['id'];
    mysqli_query($link, $sql);
}
 * 
 */


